#!/bin/bash
# 动态打印函数
print_with_delay() {
  local text="$1"
  local delay=0.01
  for ((i=0; i<${#text}; i++)); do
    echo -n "${text:$i:1}"
    sleep $delay
  done
  echo
}
# 配置指令
config_commands="UNLOGALL COM1
UNLOGALL COM2
UNLOGALL COM3
LOG COM1 GPGGA ONTIME 1 
LOG COM2 GPGGA ONTIME 1 
LOG COM3 GPGGA ONTIME 1 

LOG ICOM1 INSPVAXB ONTIME 0.02
LOG ICOM1 INSPVAB ONTIME 0.02
LOG ICOM1 BESTPOSB ONTIME 0.05
LOG ICOM1 BESTGNSSVELB ONTIME 0.2
LOG ICOM1 CORRIMUDATAB ONNEW
LOG ICOM1 RAWIMUB ONNEW
LOG ICOM1 HEADING2 ONTIME 1

RAWIMUOUT ON

SETINSTRANSLATION ANT1 -0.36 0.096 0.91 0.05 0.05 0.05 VEHICLE
SETINSTRANSLATION ANT2 0.36 0.096 0.91 0.05 0.05 0.05 VEHICLE
SETINSTRANSLATION User 0 -0.213 -0.39  0.05 0.05 0.05 VEHICLE

SETINSROTATION RBV 0 0 90

SAVECONFIG
REBOOT"

# 将配置指令复制到剪切板
echo -e "$config_commands" | xclip -selection clipboard

# 打印消息
echo -e "--------------------------------------${NC}"
print_with_delay "已将配置指令复制到剪切板中, 即将打开cutecom, 请确保Device为 /dev/ttyS3, 在 cutecom 中点击 open , 在input一栏中粘贴指令, 然后按下回车"
echo -e "--------------------------------------${NC}"
print_with_delay "按下回车后等待15s左右, 如果cutecom中开始按照1秒1次的频率打印 GPGGA, 说明配置成功,关闭cutecom即可"
echo -e "--------------------------------------${NC}"
# 打开 sudo cutecom
sudo cutecom
